package com.neusoft.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.neusoft.po.Business;

@Mapper
public interface BusinessMapper {
	@Select("select * from business where orderTypeId=#{orderTypeId} order by businessId")
	public List<Business> listBusinessByOrderTypeId(Integer orderTypeId);

	@Select("select * from business where businessId=#{businessId}")
	public Business getBusinessById(Integer businessId);

	@Select("select * from business order by star")
	public List<Business> listBusinessOrderByStarAsc();

	@Select("select * from business order by sales")
	public List<Business> listBusinessOrderBySalesAsc();

	@Select("select * from business order by star desc")
	public List<Business> listBusinessOrderByStarDesc();

	@Select("select * from business order by sales desc")
	public List<Business> listBusinessOrderBySalesDesc();

	@Update("update business set sales=sales+1 where businessId=#{businessId}")
	public int addSalesByBusinessId(Integer businessId);

	//for search
	@Select("select * from business where businessName like CONCAT('%',#{businessName},'%')")
	public List<Business> searchBusiness(String businessName);

}
